package com.llw.haha.springboot.test.service;

import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Component
public class ShowConfigService {
    @Resource
    private Environment environment;


    @PostConstruct
    private void init() {
        List<String> list = new ArrayList<>();
        list.add("server.port");
        list.add("spring.application.name");
        list.add("spring.datasource.druid.url");
        list.add("spring.datasource.druid.username");
        list.add("spring.datasource.druid.password");
        list.add("logging.path");
        list.add("dataPath");
        for (String s : list) {
            final String property = environment.getProperty(s);
            System.out.printf("%s:%s%n", s, property);
        }


    }
}
